var path = require("path");
var webpack = require("webpack");
var HtmlWebpackPlugin = require('html-webpack-plugin');
var VueLoaderPlugin = require('vue-loader/lib/plugin');

module.exports = {
    entry:path.join(__dirname,'./src/main.js'),//webpack打包的入口文件
    output:{//webpack输出的文件信息
        path:path.join(__dirname,'./dist'),
        filename:'bundle.js'
    },
    mode: 'development',//?
    devServer:{
        open:true,//自动开启浏览器
        port:'3000',//配置应用的端口
        hot:true,//开启热模块替换的第一步
        contentBase:path.join(__dirname,'./src'),//指定启动根目录
        // host:'192.168.23.1'
    },
    plugins:[
        new webpack.HotModuleReplacementPlugin(),//开启热模块替换的第二步
        new HtmlWebpackPlugin({
            filename: 'index.html',
            template: path.join(__dirname,'./src/index.html')
        }),
        new VueLoaderPlugin()
    ],
    module: {
        rules: [
          { test: /\.css$/, use: ['style-loader','css-loader'] },
          { test: /\.less$/, use: ['style-loader','css-loader','less-loader'] },
          { test: /\.vue$/, use: 'vue-loader' },
          { test: /\.(ttf|woff)$/, use: 'url-loader' }
        ]
    }
}